package com.wash.car.web.controller.applets;

import com.github.pagehelper.PageInfo;
import com.pmo.boot.common.api.DefaultResult;
import com.wash.car.biz.StoreServer;
import com.wash.car.dao.model.StoreDetailsModel;
import com.wash.car.dao.model.StorePageModel;
import com.wash.car.dao.model.StorePageWhereModel;
import com.wash.car.dao.model.StoreWhereModel;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = {"门店管理"})
@RestController
@RequestMapping(path = "/applets/store")
public class AppletsStoreController {
    @Autowired
    private StoreServer storeServer;

    @ApiOperation(value = "根据id查询门店")
    @GetMapping(path = "getStore/{id}")
    public DefaultResult<StoreDetailsModel> getStore(@PathVariable(value = "id") Long id) {
        StoreDetailsModel model = storeServer.findStore(new StoreWhereModel().setStoreId(id));
        return DefaultResult.success(model);
    }

    @ApiOperation(value = "查询全部门店")
    @GetMapping(path = "getAllStores")
    public DefaultResult<PageInfo<StorePageModel>> getAllStores(StorePageWhereModel model) {
        return DefaultResult.success(storeServer.page(model));
    }

}
